package top.lingchen.blogadmin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.lingchen.blogadmin.bean.Admin;
import top.lingchen.blogadmin.bean.Permission;
import top.lingchen.blogadmin.mapper.AdminMapper;
import top.lingchen.blogadmin.service.AdminService;

import java.util.List;

/**
 * @Author 凌宸
 * @create 2021-12-20 下午 2:31
 * @Description
 * @Version 1.0
 */
@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin findAdminByUsername(String username) {
        LambdaQueryWrapper<Admin> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Admin::getUsername, username);
        wrapper.last("limit 1");
        Admin admin = adminMapper.selectOne(wrapper);
        return admin;
    }

    @Override
    public List<Permission> findPermissionByAdminId(Long adminId) {
        return adminMapper.findPermissionByAdminId(adminId);
    }
}
